<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}首页{% endblock %}

{% block page_content %}
<!-- 监控数据 -->
<div class="card mt10">
    <h5 class="card-header">
        <button class="btn btn-sm btn-primary right" type="button">刷新</button>
    </h5>
    <div class="card-body">
        <table class="table">
            <thead>
            <tr>
                <th>名称</th>
                <th>状态</th>
                <th>启动用户</th>
                <th>上报时间</th>
                <th>进程ID</th>
                <th>主机地址</th>
                <th>错误编码</th>
                <th>错误信息</th>
                <th>节点操作</th>
            </tr>
            </thead>
            <!-- 监控数据信息 -->
            <tbody>
            {% for heartbeat in heartbeats %}
            <tr class="{% if heartbeat.service_status == 'DOWN' %}down_background{% endif %}">
                <td>{{heartbeat['service_name']}}</td>
                <td>
                    <i class="fa {% if heartbeat.service_status == 'UP' %}fa-thumbs-up up {% else %}fa-thumbs-down down{% endif %}"
                       data-toggle="tooltip" data-placement="top"
                       title="{% if heartbeat.service_status == 'UP' %}当前服务运行正常{% else %}当前服务已宕机{% endif %}"></i>
                </td>
                <td>{{heartbeat['service_username']}}</td>
                <td>{{heartbeat['service_timestamp']}}</td>
                <td>{{heartbeat['service_pid']}}</td>
                <td>{{heartbeat['service_host']}}</td>
                <td>{{heartbeat['service_code']}}</td>
                <td>
                    {% if heartbeat.service_message %}
                    <i class="fa fa-exclamation-triangle" data-toggle="tooltip" data-placement="top"
                       title="{{heartbeat['service_message']}}"></i>
                    {% endif %}
                </td>
                <td>
                    <i class="fa {% if heartbeat.service_status == 'UP' %}fa-stop down{% else %}fa-play up{% endif %}"
                       data-toggle="tooltip" data-placement="top"
                       title="{% if heartbeat.service_status == 'UP' %}下线节点{% else %}启动服务{% endif %}"></i>
                </td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
</div>

{#<p>{{ moment(current_time).format('LLL') }}</p>#}
{#<p>{{ moment(current_time).fromNow(refresh=True) }}</p>#}

{% endblock %}
